import pytest
import os
from common.constant import CommonErrorInfo
from common.settings import logger


# 默认单进程执行用例
def run(num_of_process: int = 1) -> None:
    if num_of_process == 1:
        params_lst = ['-s', '--alluredir', './report/tmp', '--clean-alluredir']
    elif num_of_process > 1:
        params_lst = ['-s', f'-n={num_of_process}', '--alluredir', './report/tmp', '--clean-alluredir']
    else:
        logger.error(CommonErrorInfo.NUM_OF_PROCESS_IS_WRONG.value)
        raise ValueError(CommonErrorInfo.NUM_OF_PROCESS_IS_WRONG.value)
    pytest.main(params_lst)
    os.system(r'allure generate ./report/tmp -o ./report/html --clean')


if __name__ == '__main__':
    run()
